#include "Complex.h"
#include <iostream>
void Complex::setreal(double real)
{
	this->real = real;
}

void Complex::setimag(double imag)
{
	this->imag = imag;
}

double Complex::getreal()
{
	return this->real;
}

double Complex::getimag()
{
	return this->imag;
}


void Complex::display()
{
	std::cout << real << "+" << imag << "i" << std::endl;
}

Complex operator+(Complex a, Complex b)
{
	return Complex(a.real + b.real, a.imag + b.imag);
}

Complex operator-(Complex a, Complex b)
{
	return Complex(a.real - b.real, a.imag - b.imag);
}

Complex operator*(Complex a, Complex b)
{
	return Complex(a.real * b.real + a.imag * b.imag, a.imag * b.real + a.real * b.imag);
}

Complex operator/(Complex a, Complex b)
{
	/*
	(a.real + a.imag*i) / (b.real + b.imag*i)
	(a.real + a.imag*i)*(b.real - b.imag*i) / (b.real*b.real+b.imag*b.imag)
	a.real*b.real+a.imag*b.imag+a.imag*i*b.real-a.real*b.imag*i
	*/
	return Complex((a.real * b.real + a.imag * b.imag) / (b.real * b.real + b.imag * b.imag),
		(a.imag * b.real - a.real * b.imag) / (b.real * b.real + b.imag * b.imag));
}
